<title>保险商城</title>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <div class="layui-row layui-col-space20">
        <div class="layui-col-md12 LAY_mall_flex_wrap">
          <div class="LAY_wisdom_title LAY_mall_flex_title">
            <h3 class="LAY_wisdom_title_line">商城地址</h3>
          </div>
            
          <div class="layui-row LAY_wisdom_list_row LAY_mall_flex_content LAY_mall_adress"></div>
        </div>
      </div>

      <hr style="margin: 30px 0;">

      <div class="layui-row layui-col-space20 layui-form" lay-filter="LAY_mall_form">
        <div class="layui-col-md12 LAY_mall_flex_wrap">
          <div class="LAY_wisdom_title LAY_mall_flex_title">
            <h3 class="LAY_wisdom_title_line">商城名称</h3>
          </div>

          <div class="layui-row LAY_wisdom_list_row LAY_mall_flex_content LAY_mall_flex_box">
            <input type="text" name="shopName" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input LAY_mall_flex_10">
            <button class="layui-btn LAY_jhzb_btn_save LAY_mall_flex_1">保存</button>
          </div>
        </div>
      </div>

      <hr style="margin: 30px 0;">

      <!-- 爆款设置 -->
      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <div class="LAY_wisdom_title">
            <h3 class="LAY_wisdom_title_line">爆款设置</h3>
          </div>

          <div class="layui-row LAY_wisdom_list_row">
            <div class="layui-col-md10 layui-col-md-offset2">
              <div class="list-group col LAY_wisdom_scroll" id="LAY_hot_list_view"></div>

              <script type="text/html" id="LAY_hot_list_tpl">
                {{# if (d.length) { }}
                  {{# layui.each(d, function(index, item){ }} 
                    <div class="list-group-item LAY_wisdom_list_warp" data-code="{{item.productCode}}"
                      data-name="{{item.productName}}" data-sort="">
                      <div class="LAY_wisdom_list_item{{item.active ? ' active' : ''}}">
                        {{item.productName}}
                      </div>
                      <div class="LAY_wisdom_list_btn_group">
                        <div class="LAY_wisdom_list_btn_up LAY_hot_list_btn_up" data-code="{{item.productCode}}" data-index="{{index}}">
                          <i class="layui-icon layui-icon-up"></i>
                        </div>
                        <div class="LAY_wisdom_list_btn_delete LAY_color_red LAY_hot_list_btn_delete" data-code="{{item.productCode}}">
                          <i class="layui-icon layui-icon-delete"></i>
                        </div>
                        <div class="LAY_wisdom_list_btn_down LAY_hot_list_btn_down" data-code="{{item.productCode}}" data-index="{{index}}">
                          <i class="layui-icon layui-icon-down"></i>
                        </div>
                      </div>
                    </div>
                  {{# }) }}
                {{# } else { }}
                  <div class="LAY_empty">暂无数据</div>
                {{# } }}
              </script>
            </div>
          </div>
        </div>
        <div class="layui-col-md6">
          <div class="LAY_wisdom_title">
            <h3>产品库</h3>
          </div>

          <div class="LAY_wisdom_product_search">
            <form class="layui-form LAY_wisdom_product_search_form" lay-filter="LAY_wisdom_product_search_form">
              <input type="text" name="productName" placeholder="请输入产品名称" autocomplete="off" class="layui-input">
              <button lay-submit class="layui-btn" lay-submit lay-filter="LAY_wisdom_product_search_btn">
                <i class="layui-icon layui-icon-search"></i>
              </button>
            </form>
          </div>
          
            <div class="LAY_wisdom_list_view" id="LAY_wisdom_product_list_view"></div>
            
            <script type="text/html" id="LAY_wisdom_product_list_tpl">
              <form class="layui-form" lay-filter="LAY_wisdom_product_list_form">
                {{# if (d && d.length) { }}
                  {{# layui.each(d, function(index, item){ }} 
                    <div class="LAY_wisdom_product_list_row">
                    <div class="LAY_wisdom_product_list_checkbox LAY_wisdom_product_list_square"></div>
                      <div class="LAY_wisdom_product_list_card">
                        {{item.productName}}
                      </div>
                      <div class="LAY_wisdom_product_list_button">
                        <button type="button" class="layui-btn LAY_hot_add" data-name="{{item.productName}}" data-code="{{item.productCode}}">
                          <i class="layui-icon layui-icon-addition"></i>
                        </button>
                      </div>
                    </div>
                  {{# }) }}
                {{# } else { }}
                  <div class="LAY_empty">暂无数据</div>
                {{# } }}
              </form>
            </script>
        </div>
      </div>

      <hr style="margin-top: 30px;">

      <!-- 产品中心 -->
      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <div class="LAY_wisdom_title">
            <h3 class="LAY_wisdom_title_line">产品中心</h3>
          </div>

          <div class="layui-row LAY_wisdom_list_row">
            <div class="layui-col-md2">
              <div class="layui-tab layui-tab-brief" lay-filter="LAY_product_center_tab">
                <ul class="layui-tab-title LAY_product_center_tab_title" id="LAY_product_center_tab_view"></ul>

                <script type="text/html" id="LAY_product_center_tab_tpl">
                  {{#  layui.each(d, function(index, item){ }}
                    <li class="{{index == 0 ? 'layui-this' : ''}}" data-code="{{item.categoryCode}}">{{ item.name }}</li>
                  {{#  }); }}
                </script>
              </div> 
            </div>
            <div class="layui-col-md10">
              <div class="list-group col LAY_wisdom_scroll" id="LAY_product_center_view"></div>

              <script type="text/html" id="LAY_product_center_tpl">
                {{# if (d.length) { }}
                  {{# layui.each(d, function(index, item){ }} 
                    <div class="list-group-item LAY_wisdom_list_warp" data-code="{{item.productCode}}"
                      data-name="{{item.productName}}" data-sort="">
                      <div class="LAY_wisdom_list_item{{item.active ? ' active' : ''}}">
                        {{item.productName}}
                      </div>
                      <div class="LAY_wisdom_list_btn_group">
                        <div class="LAY_wisdom_list_btn_up LAY_product_center_btn_up" data-code="{{item.productCode}}" data-index="{{index}}">
                          <i class="layui-icon layui-icon-up"></i>
                        </div>
                        <div class="LAY_wisdom_list_btn_delete LAY_color_red LAY_product_center_btn_delete" data-code="{{item.productCode}}">
                          <i class="layui-icon layui-icon-delete"></i>
                        </div>
                        <div class="LAY_wisdom_list_btn_down LAY_product_center_btn_down" data-code="{{item.productCode}}" data-index="{{index}}">
                          <i class="layui-icon layui-icon-down"></i>
                        </div>
                      </div>
                    </div>
                  {{# }) }}
                {{# } else { }}
                  <div class="LAY_empty">暂无数据</div>
                {{# } }}
              </script>
            </div>
          </div>
        </div>
        <div class="layui-col-md6">
          <div class="LAY_wisdom_title">
            <h3>产品库</h3>
            <!-- <button class="layui-btn LAY_hot_batch_add">一键添加</button> -->
          </div>

          <div class="LAY_wisdom_product_search">
            <form class="layui-form LAY_wisdom_product_search_form" lay-filter="LAY_wisdom_product_center_search_form">
              <input type="text" name="productName" placeholder="请输入产品名称" autocomplete="off" class="layui-input">
              <button lay-submit class="layui-btn" lay-submit lay-filter="LAY_wisdom_product_center_search_btn">
                <i class="layui-icon layui-icon-search"></i>
              </button>
            </form>
          </div>
          
          <div class="LAY_wisdom_list_view" id="LAY_wisdom_product_center_list_view"></div>
          
          <script type="text/html" id="LAY_wisdom_product_center_list_tpl">
            <form class="layui-form" lay-filter="LAY_wisdom_product_center_list_form">
              {{# if (d && d.length) { }}
                {{# layui.each(d, function(index, item){ }} 
                  <div class="LAY_wisdom_product_list_row">
                    <div class="LAY_wisdom_product_list_checkbox LAY_wisdom_product_list_square"></div>
                    <div class="LAY_wisdom_product_list_card">
                      {{item.productName}}
                    </div>
                    <div class="LAY_wisdom_product_list_button">
                      <button type="button" class="layui-btn LAY_product_center_add" data-name="{{item.productName}}" data-code="{{item.productCode}}">
                        <i class="layui-icon layui-icon-addition"></i>
                      </button>
                    </div>
                  </div>
                {{# }) }}
              {{# } else { }}
                <div class="LAY_empty">暂无数据</div>
              {{# } }}
            </form>
          </script>
        </div>
      </div>

      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <div class="layui-col-md10 layui-col-md-offset2">
            <button class="layui-btn layui-btn-primary LAY_btn_preview">查看保险商城</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  layui.use(['admin', 'form', 'laypage', 'laytpl', 'hot', 'qrcode', 'clipboard',
    'hotProductLibrary', 'center', 'centerProductLibrary', 'preview'], function () {
    var $ = layui.$,
      admin = layui.admin,
      setter = layui.setter,
      view = layui.view,
      table = layui.table,
      laytpl = layui.laytpl,
      laypage = layui.laypage,
      element = layui.element,
      form = layui.form,
      hot = layui.hot,
      hotProductLibrary = layui.hotProductLibrary,
      center = layui.center,
      centerProductLibrary = layui.centerProductLibrary,
      preview = layui.preview;

    var orgCode;

    hot.init(function () {
      hotProductLibrary.init();
    });

    center.init(function () {
      centerProductLibrary.init();
    });
    
    form.render(null, 'LAY_mall_form');

    $('.LAY_jhzb_btn_save').off('click').on('click', function () {
      var field = form.val('LAY_mall_form');
      var params = $.extend(true, { orgCode: orgCode }, field)

      admin.req({
        url: setter.url + '/org/updateShopName',
        data: params,
        type: 'POST',
        done: function (res) {
          layer.msg('操作成功', {
            icon: 1,
            time: 1500,
            shade: [0.3, '#393D49']
          });
        }
      });
    });

    admin.req({
      url: setter.url + '/product/mallInfo',
      type: 'GET',
      done: function (res) {
        var data = res.data || [];

        orgCode = data.orgCode;
        $('.LAY_mall_adress').html(data.url);
        form.val('LAY_mall_form', {
          shopName: data.name
        });
    
        preview.init(data.url);
      }
    });
          
  });
</script>